<link rel="stylesheet" href="<?php echo base_path() ?>css/style.dev1.css" />
<link rel="stylesheet" href="<?php echo base_path() ?>plupload/style/style.css" />
<script type="text/javascript" src="<?php echo base_path() ?>plupload/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_path() ?>plupload/js/plupload.js"></script>
<script type="text/javascript" src="<?php echo base_path() ?>plupload/js/plupload.flash.js"></script>
<script type="text/javascript" src="<?php echo base_path() ?>plupload/js/plupload.html5.js"></script>
<script type="text/javascript" src="<?php echo base_path() ?>plupload/js/script.js"></script>

<script type="text/javascript" src="<?php echo base_path() ?>js/jquery.validate.min.js"></script>
<script type="text/javascript" src="<?php echo base_path() ?>js/script.category.js"></script>
<form name="add_brand" id="add_brand" action="" method="POST" onsubmit="return submitBrand();">
    <div>
        <div class="node-form">
            <div class="standard">

                <div class="form-item">
                    <label for="brand_name">Tên thương hiệu: <span title="Trường bắt buộc." class="form-required">*</span></label>
                    <input type="text" value="<?php if(!empty($data['brand'])) echo $data['brand']->brand_name; ?>" size="60" id="brand_name" name="brand_name" maxlength="100">
                </div>
                
                <div class="form-item">
                    <label for="brand_index">Tên viết tắt:</label>
                    <input type="text" value="<?php if(!empty($data['brand'])) echo $data['brand']->brand_index; ?>" size="10" id="brand_index" name="brand_index" maxlength="5">
                </div>
                
                <div class="form-item">
                    <label for="brand_position">Độ ưu tiên:</label>
                    <input type="text" value="<?php if(!empty($data['brand'])) echo $data['brand']->brand_position; else echo 1; ?>" size="5" id="brand_position" name="brand_position" maxlength="3">
                </div>
                <div class="form-item">                    
                    <a id="pickfiles" href="javascript:;">[Chọn logo]</a>                    
                    <?php
                        if(!empty($data['brand'])) {
                    ?>        
                        <script type="text/javascript">
                            $(function(){
                                settings.max_file_temp = 1;
                                removeImage(<?php echo $data['brand']->brand_id ?>, 'files/brand');
                            });
                        </script>
                            <div id="thumbnails">                            
                            <div class="thumb" id="thumb_<?php echo $data['brand']->brand_id ?>">
                                <div class="thumb_cell">
                                    <img title="" alt="" src="<?php echo base_path() ?>plupload/lib/phpThumb/phpThumb.php?src=/files/brand/<?php echo $data['brand']->file_path ?>&amp;w=100&amp;q=100">
                                    <a class="remove" id="<?php echo $data['brand']->brand_id ?>" filename="<?php echo $data['brand']->file_path ?>" title="Remove"></a>
                                </div>
                            </div>
                            </div>
                    <?php        
                        } else {
                            echo '<div id="thumbnails"></div>';
                        }
                    ?>
                    <input type="hidden" value="<?php if(!empty($data['brand'])) echo $data['brand']->file_path; ?>" id="thumbnail" name="thumbnail" readonly="true" />
                    <div class="clean"></div>                    
                </div>
                
                <?php
                    if(user_access('admin block')) {
                ?>
                <div class="form-item">
                    <label for="brand_status">Trạng thái:</label>
                    <select id="brand_status" name="brand_status">
                        <option value="<?php echo BRAND_STATUS_SHOW ?>">Hiển thị</option>
                        <option <?php if(!empty($data['brand']) && $data['brand']->brand_status == BRAND_STATUS_HIDE) echo 'selected="true"'; ?> value="<?php echo BRAND_STATUS_HIDE ?>">Không hiển thị</option>
                    </select>
                </div>
                <?php
                    } else {
                        echo '<input type="hidden" value="' . ($data['brand']->brand_status == BRAND_STATUS_HIDE ? BRAND_STATUS_HIDE : BRAND_STATUS_SHOW) . '" id="brand_status" name="brand_status" readonly="true" />';
                    }
                ?>
                
                <div class="form-item">
                    <input type="submit" value="Lưu" />
                    <input type="reset" rel="add_brand" value="Nhập lại" />                
                    <?php echo l('Quay lại', 'back-end/filter/brand/' . arg(3)) ?>
                </div>
                
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
$(function(){
    settings.max_file_upload = 1;
    settings.upload_path = 'files/brand';
    settings.url = '/upload.php?path=' + settings.upload_path + '&action=brand';
    settings.create_thumb = true;
    settings.max_file_size = '1mb';
    uploader = new plupload.Uploader(settings);
    uploader.init();
});
</script>